<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>你好，请<a href="login.html">登录</a></h1>
    <h1>欢迎，<span>xxx</span></h1>
    <hr>
    <a href="./list.html">去列表</a>
</body>
<script src="./axios.js"></script>
<script>
    var oh1 = document.querySelectorAll("h1")
    var oSpan = document.querySelector("span")

    oh1[0].style.dispaly = 'block'
    oh1[1].style.dispaly = 'none'

    axios({
        method: "get",
        url:"http://localhost:8888/users/info",
        params: {
            id: localStorage.getItem("id")
        },
        headers: {
            "authorization": localStorage.getItem("token")
        },
        
    }).then(res => {
        console.log(res)
        if(res.data.code != 1){
            oh1[0].style.dispaly = 'block'
            oh1[1].style.dispaly = 'none'
            return;
        }
        oh1[0].style.display = 'none'
        oh1[1].style.display = 'block'
        oSpan.innerText = res.data.info.username
    })
</script>
</html>